import pandas as pd

advertising = pd.read_csv("/Users/xiaojian/PycharmProjects/ml_tutorial/data/advertising.csv")
advertising.drop(advertising.columns[0], axis=1, inplace=True)
advertising.dropna(inplace=True)
X = advertising.drop("Sales", axis=1)
y = advertising["Sales"]
# 计算皮尔逊相关系数
print(X.corrwith(y, method="pearson"))
# print(advertising.head())
# TV           0.782224
# Radio        0.576223
# Newspaper    0.228299
# dtype: float64